package undoRedo;

/*
 * Stack implementation for undo/redo 
 */
import java.util.*;
//import cuShapes.PQShape;

/*
 * @author: Daniel Miller
 */

public class UndoRedo implements Stack {

	private LinkedList<Object> undoRedoStack;
	public static UndoRedo action;
	
	protected UndoRedo()
	{
		undoRedoStack = new LinkedList<Object>();
	}
	
	public static UndoRedo getInst()
	{
		if(action == null)
		{
			action = new UndoRedo();
		}
		return action;
	}
	public void clear() {
		// TODO Auto-generated method stub
		undoRedoStack.clear();

	}

	@Override
	public Object getTop() {
		// TODO Auto-generated method stub
		return undoRedoStack.getFirst();
	}

	@Override
	public Object pop() {
		// TODO Auto-generated method stub
		Object popItem = null;
		if (undoRedoStack.size() > 0)
		{
			popItem = undoRedoStack.pop();
		}
		return popItem;
	}

	@Override
	public void push(Object o) {
		// TODO Auto-generated method stub
		
		undoRedoStack.push(o);

	}
	
	public int getSize()
	{
		return undoRedoStack.size();
	}

}
